import request from '../utils/request';
import * as constants from '../constants';

export async function fetch({pageNumber = 1}) {
  // const json = await request(constants.BASIC_URL + `/module/clientPageByTownIdAndPId?pageNumber=${pageNumber}&pageSize=${constants.PAGE_SIZE}&townId=13&parentId=0`);
  const json = await request(constants.BASIC_URL + `/json/getModuleList?pageNumber=${pageNumber}&pageSize=${constants.PAGE_SIZE}`);
  return json;
};

export async function add(module) {
  const json = await request(constants.BASIC_URL + `/json/addModule` , {
    headers: {
      "Content-Type": "application/json"
    },
    method : 'POST',
    body : JSON.stringify(module),
  });
  return json;
};

export async function edit(module) {
  const json = await request(constants.BASIC_URL + `/json/editModule` , {
    headers: {
      "Content-Type": "application/json"
    },
    method : 'POST',
    body : JSON.stringify(module),
  });
  return json;
};

export async function del(id) {
  const json = await request(constants.BASIC_URL + `/json/deleteModule?id=${id}`);
  return json;
};
